﻿using System;
using System.Data;
public partial class manager_eval_Default : System.Web.UI.Page
{
    DBHelper db = new DBHelper();
    public string HtmlTitle = "";
    public DateTime DelRq;
    protected void Page_Load(object sender, EventArgs e)
    {
        DateTime ss = DateTime.Now;
        DelRq = ss.AddMonths(-2);

        if (!IsPostBack)
        {
            bindData();
        }
    }
    private void bindData()
    {
        string userbh = Session[AppConfig.SESSION_USER_BH].ToString();
        DataTable dttitle = db.getList("select * from A_Eval_Sys where state=0");
        HtmlTitle = dttitle.Rows[0]["year"].ToString() + "年" + dttitle.Rows[0]["month"].ToString() + "月考勤,开始日期" + Convert.ToDateTime(dttitle.Rows[0]["rq_start"].ToString()).ToString("yyyy-MM-dd") + ",结束日期" + Convert.ToDateTime(dttitle.Rows[0]["rq_end"].ToString()).ToString("yyyy-MM-dd");

    }


    #region 生成本月考评记录
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        SQ_Eval Ev = new SQ_Eval();
        Ev.StartEval("1");
    }
    #endregion

    #region 当月考评开始
    protected void btnUpdate_Click8(object sender, EventArgs e)
    {
        int now_year = 0;
        int now_month = 0;
        string now_kq_s_d;
        string now_kq_e_d;
        DateTime now = DateTime.Now;
        int day = now.Day;
        if (day >= 26)
        {
            now_year = now.AddMonths(1).Year;
            now_month = now.AddMonths(1).Month;
            now_kq_s_d = now.Year.ToString() + "-" + now.Month.ToString() + "-26";
            now_kq_e_d = now.AddMonths(1).Year.ToString() + "-" + now.AddMonths(1).Month.ToString() + "-25";
        }
        else
        {
            now_year = now.Year;
            now_month = now.Month;
            now_kq_s_d = now.AddMonths(-1).Year.ToString() + "-" + now.AddMonths(-1).Month.ToString() + "-26";
            now_kq_e_d = now.Year.ToString() + "-" + now.Month.ToString() + "-25";
        }

        string sql = "select * from A_Eval_Sys where [state]=0";
        DataTable dt = db.getList(sql);
        if (dt.Rows.Count == 1)
        {
            int sys_year = Convert.ToInt32(dt.Rows[0]["year"].ToString());
            int sys_month = Convert.ToInt32(dt.Rows[0]["month"].ToString());
            string sys_rq_start = dt.Rows[0]["rq_start"].ToString();
            string sys_rq_end = dt.Rows[0]["rq_end"].ToString();
            if (sys_year != now_year || sys_month != now_month)
            {
                sql = "update A_Eval_Sys set [state]=1";
                db.executeNoneQuery(sql);
                sql = "insert into A_Eval_Sys(year,month,rq_start,rq_end,[state]) values(" + now_year + "," + now_month + ",'" + now_kq_s_d + "','" + now_kq_e_d + "',0)";
                db.executeNoneQuery(sql);
                Response.Write(CommonHelper.alertMsgAndRedirect("本月考评开始，是不是信心满满呢O(∩_∩)O~", "default.aspx"));
            }
            else
            {
                Response.Write(CommonHelper.alertMsgAndRedirect("现在的考评不就是本月的吗？？别乱点/(ㄒoㄒ)/~~", "default.aspx"));
            }
        }
    }
    #endregion

    #region 生成本月固定任务
    protected void Button2_Click(object sender, EventArgs e)
    {
        SQ_Eval Ev = new SQ_Eval();
        Ev.StartEval("2");
    }
    #endregion

    #region 生成本月固定任务
    protected void Button3_Click(object sender, EventArgs e)
    {
        SQ_Eval Ev = new SQ_Eval();
        Ev.StartEval("3");
    }
    #endregion

    #region 计算本月任务得分
    protected void Button4_Click(object sender, EventArgs e)
    {
        SQ_Eval Ev = new SQ_Eval();
        Ev.StartEval("4");
    }
    #endregion

    #region 生成本月特殊考评
    protected void Button5_Click(object sender, EventArgs e)
    {
        SQ_Eval Ev = new SQ_Eval();
        Ev.StartEval("5");
    }
    #endregion
}